
#include <stdio.h>
#include <stdlib.h>

/**
 * 验证进程地址空间分布
 */

int un_g_val;
int g_val = 10;

int main()
{
    int *p1 =(int*)malloc(16);
    int *p2 =(int*)malloc(16);
    int *p3 =(int*)malloc(16);
    int *p4 =(int*)malloc(16);
    printf("Code:   %p\n",main);      //代码区
    printf("Init:   %p\n",&g_val);    //初始化数据区
    printf("Uninit: %p\n",&un_g_val); //未初始化数据区
    printf("Heap:   %p\n",p1);        //堆区
    printf("Heap:   %p\n",p2);   
    printf("Heap:   %p\n",p3);   
    printf("Heap:   %p\n",p4);   
    printf("Stack:  %p\n",&p1);       //栈区
    printf("Stack:  %p\n",&p2);
    printf("Stack:  %p\n",&p3);
    printf("Stack:  %p\n",&p4);

    return 0;
}
